package com.jidu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jidu.common.utils.poi.ExcelUtil;
import com.jidu.domain.ClassTimeConfig;
import com.jidu.service.IClassTimeConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jidu.common.annotation.Log;
import com.jidu.common.core.controller.BaseController;
import com.jidu.common.core.domain.AjaxResult;
import com.jidu.common.enums.BusinessType;
import com.jidu.common.core.page.TableDataInfo;

/**
 * 班级上课时间安排配置Controller
 * 
 * @author xuliang
 * @date 2024-07-25
 */
@Slf4j
@Api(tags = "班级上课时间安排配置 controller")
@RestController
@RequestMapping("/class/time/config")
public class ClassTimeConfigController extends BaseController
{
    @Autowired
    private IClassTimeConfigService classTimeConfigService;

    /**
     * 查询班级上课时间安排配置列表
     */
    @ApiOperation(value = "查询班级上课时间安排配置列表")
    @PreAuthorize("@ss.hasPermi('system:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClassTimeConfig classTimeConfig)
    {
        startPage();
        List<ClassTimeConfig> list = classTimeConfigService.selectClassTimeConfigList(classTimeConfig);
        return getDataTable(list);
    }

    /**
     * 导出班级上课时间安排配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:config:export')")
    @Log(title = "班级上课时间安排配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClassTimeConfig classTimeConfig)
    {
        List<ClassTimeConfig> list = classTimeConfigService.selectClassTimeConfigList(classTimeConfig);
        ExcelUtil<ClassTimeConfig> util = new ExcelUtil<ClassTimeConfig>(ClassTimeConfig.class);
        util.exportExcel(response, list, "班级上课时间安排配置数据");
    }

    /**
     * 获取班级上课时间安排配置详细信息
     */
    @ApiOperation(value = "获取班级上课时间安排配置详细信息")
    @PreAuthorize("@ss.hasPermi('system:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(classTimeConfigService.selectClassTimeConfigById(id));
    }

    /**
     * 新增班级上课时间安排配置
     */
    @ApiOperation(value = "新增班级上课时间安排配置")
    @PreAuthorize("@ss.hasPermi('system:config:add')")
    @Log(title = "班级上课时间安排配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClassTimeConfig classTimeConfig)
    {
        return toAjax(classTimeConfigService.insertClassTimeConfig(classTimeConfig));
    }

    /**
     * 修改班级上课时间安排配置
     */
    @ApiOperation(value = "修改班级上课时间安排配置")
    @PreAuthorize("@ss.hasPermi('system:config:edit')")
    @Log(title = "班级上课时间安排配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClassTimeConfig classTimeConfig)
    {
        return toAjax(classTimeConfigService.updateClassTimeConfig(classTimeConfig));
    }

    /**
     * 删除班级上课时间安排配置
     */
    @ApiOperation(value = "逻辑删除班级上课时间安排配置")
    @PreAuthorize("@ss.hasPermi('system:config:remove')")
    @Log(title = "班级上课时间安排配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(classTimeConfigService.deleteClassTimeConfigByIds(ids));
    }
}
